package org.budo.support.nio.channel.util;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.SeekableByteChannel;

/**
 * @author lmw
 */
public class ChannelUtil {
    public static void position(SeekableByteChannel seekableByteChannel, long newPosition) {
        try {
            seekableByteChannel.position(newPosition);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public static int read(SeekableByteChannel seekableByteChannel, ByteBuffer byteBuffer) {
        try {
            return seekableByteChannel.read(byteBuffer);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
